package com.gph.saviorframework.dao.security;

import com.gph.saviorframework.base.dao.BaseDao;
import com.gph.saviorframework.common.model.ResourcePermission;
import org.apache.ibatis.annotations.Param;
import org.aspectj.lang.annotation.Aspect;

import java.util.List;
import java.util.Map;

/**
 * 数据权限dao
 *
 * @author guopeihui
 */
@Aspect
public interface ResourcePermissionDao extends BaseDao<ResourcePermission,String>{

    List<ResourcePermission> getByUserId(@Param(value = "userId")String userId);

    ResourcePermission getByUserIdAndResourceType(@Param(value = "userId")String userId,
                                                  @Param(value = "resourceType")String resourceType);

    void deleteByUserId(@Param(value = "userId")String userId);

    void deleteByResourceType(@Param(value = "resType")String resType);

    void deleteByResourceTypeAndUserId(@Param(value = "userId")String userId,@Param(value = "resType")String resType);

    /**
     * 查询结果集
     * @param sort
     * @param dir
     * @param whereClause
     * @return
     */
    List<Map<String,Object>> find(
            @Param(value = "sort")String sort,
            @Param(value = "dir")String dir,
            @Param(value = "where_clause")String whereClause);

    /**
     * 返回结果集数量
     * @param whereClause
     * @return
     */
    long count(@Param(value = "where_clause")String whereClause);

}
